import React, {useEffect, useState} from 'react';
import {Space, Switch, Table,Button} from "antd";
import {getHospitalList} from "@/api/hosp";

function Index() {
    // 定义保存医院列表的数据状态
    const [hospitalList,setHospitalList] = useState([]);
    useEffect(()=>{
        getHospitalList(1,4).then((values:any)=>{
            setHospitalList(values.data.content)
        })
    },[])
    return (
        <div id={"content"}>
            <Table
                scroll={{x:1500}}
                rowKey={"id"}
                bordered={true}
                columns={[
                    {
                        title:"序号",
                        align:"center",
                        render(value,rows,index){
                            return index+1;
                        }
                    },{
                        title:"医院名称",
                        align:"center",
                        dataIndex:"hosname"
                    },{
                        title:"医院编号",
                        align:"center",
                        dataIndex:"hoscode"
                    },{
                       title:"医院LOGO",
                       align:"center",
                       dataIndex:"logoData",
                        render(logoData){
                           return (
                               <img height={50} src={"data:image/png;base64,"+logoData} alt=""/>
                           )
                        }
                    },{
                        title:"是否上线",
                        align:"center",
                        dataIndex:"status",
                        // （0：未上线 1：已上线）
                        render(status){
                            return (
                                <Switch checked={status===1}/>
                            )
                        }
                    },{
                        title:"医院等级",
                        align:"center",
                        dataIndex:"param",
                        render(param){
                            return param.hostypeString;
                        }
                    },{
                        title:"医院地址",
                        align:"center",
                        dataIndex:"param",
                        render(param){
                            return param.fullAddress;
                        }
                    },{
                        title:"创建时间",
                        align:"center",
                        dataIndex:"createTime"
                    },{
                        title:"操作",
                        align:"center",
                        fixed:"right",
                        render(){
                            return (
                                <Space>
                                    <Button type={"primary"}>查看</Button>
                                    <Button type={"primary"}>排班</Button>
                                </Space>
                            )
                        }
                    }
                ]}
                dataSource={hospitalList}
            />
        </div>
    );
}

export default Index;